﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VisualAgile.Controllers;
using System.Web.Mvc;
using System.Web.Routing;
using VisualAgile.DTO;
using VisualAgile.DTO.Mappers;
using System.Web.Security;
using System.Security.Principal;
using System.Web;
using VisualAgile.Web.Tests.Fakes;
using System.Collections;
using ProjectRouting.Controllers;

namespace VisualAgile.Web.Tests
{
    /// <summary>
    /// Summary description for FeelingsControllerTests
    /// </summary>
    [TestClass]
    public class FeelingsControllerTests : BaseControllerTests
    {
        public static FeelingsController GetController()
        {
            FeelingsController controller = new FeelingsController();
            ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
            controller.ControllerContext = controllerContext;
            return controller;
        }        

        [TestMethod]
        public void AddAction_Should_Create_And_Return_New_Feelings()
        {
            // Arrange
            var controller = GetController();

            // Act
            var result = (JsonResult)controller.Add(FeelingsDTOMapper.MapToDTO(FakeFeelingsData.FeelingBad()));

            // Results should be ResultDTO
            ResultDTO actionData = result.Data as ResultDTO;
            Assert.IsNotNull(actionData, "No results found");

            // Result should be true            
            Assert.IsTrue(actionData.Result, actionData.Message);

            // Assert
            Assert.AreEqual("Success", actionData.Message);

            //user data should not be null
            Assert.IsNotNull(actionData.Data, "No Data found");
        }

        [TestMethod]
        public void AddAction_Should_Update_And_Return_Feelings()
        {
            // Arrange
            var controller = GetController();

            var feeling = FakeFeelingsData.FeelingNormal();
            feeling.Feeling = "Good";

            // Act
            var result = (JsonResult)controller.Update(FeelingsDTOMapper.MapToDTO(feeling));

            // Results should be ResultDTO
            ResultDTO actionData = result.Data as ResultDTO;
            Assert.IsNotNull(actionData, "No results found");

            // Result should be true            
            Assert.IsTrue(actionData.Result, actionData.Message);

            // Assert
            Assert.AreEqual("Success", actionData.Message);           
        }       
    }
}
